package missile;

import java.awt.Color;
import java.awt.Graphics;

import battlestein.Agent;
/**
 * 
 * @author LocoRocoBattleStein
 *
 */
public class Laser extends Missile {

	private Agent target;
	private int initX;
	private int initY;
	/**
	 * Constructor
	 * @param posX
	 * @param posY
	 * @param finalX
	 * @param finalY
	 * @param velocity
	 * @param effectLife
	 * @param effectVelocity
	 * @param target
	 */
	public Laser(int posX, int posY, int finalX, int finalY, double velocity, int effectLife, int effectVelocity, Agent target) {
		super(posX, posY, finalX, finalY, velocity, effectLife, effectVelocity);
		initX = posX;
		initY = posY;
		
		this.target = target;
	}

	public void updatePosition() {
		this.setFinalX((int)target.getX());
		this.setFinalY((int)target.getY());
		
		this.setDirection();
		
		this.setPosX( this.getPosX() + (this.getDirX() * this.getVelocity()));
		this.setPosY( this.getPosY() + (this.getDirY() * this.getVelocity()));
	}
	
	public void draw(Graphics g) {
		g.setColor(Color.PINK);
		g.drawLine(initX, initY, (int)this.getPosX(), (int)this.getPosY());
	}

}
